import request from '@/utils/request'

// 查询环境数据统计列表
export function listStatistics(query) {
  return request({
    url: '/env/statistics/list',
    method: 'get',
    params: query
  })
}

// 查询环境数据统计详细
export function getStatistics(statisticsId) {
  return request({
    url: '/env/statistics/' + statisticsId,
    method: 'get'
  })
}

// 新增环境数据统计
export function addStatistics(data) {
  return request({
    url: '/env/statistics',
    method: 'post',
    data: data
  })
}

// 修改环境数据统计
export function updateStatistics(data) {
  return request({
    url: '/env/statistics',
    method: 'put',
    data: data
  })
}

// 删除环境数据统计
export function delStatistics(statisticsId) {
  return request({
    url: '/env/statistics/' + statisticsId,
    method: 'delete'
  })
}

// 生成日统计数据
export function generateDailyStatistics(deviceId, statisticsDate) {
  return request({
    url: '/env/statistics/generate/daily',
    method: 'post',
    params: {
      deviceId: deviceId,
      statisticsDate: statisticsDate
    }
  })
}

// 生成周统计数据
export function generateWeeklyStatistics(deviceId, statisticsDate) {
  return request({
    url: '/env/statistics/generate/weekly',
    method: 'post',
    params: {
      deviceId: deviceId,
      statisticsDate: statisticsDate
    }
  })
}

// 生成月统计数据
export function generateMonthlyStatistics(deviceId, statisticsDate) {
  return request({
    url: '/env/statistics/generate/monthly',
    method: 'post',
    params: {
      deviceId: deviceId,
      statisticsDate: statisticsDate
    }
  })
}

// 生成年统计数据
export function generateYearlyStatistics(deviceId, statisticsDate) {
  return request({
    url: '/env/statistics/generate/yearly',
    method: 'post',
    params: {
      deviceId: deviceId,
      statisticsDate: statisticsDate
    }
  })
}

// 获取环境数据趋势
export function getEnvironmentTrend(params) {
  return request({
    url: '/env/statistics/trend',
    method: 'get',
    params: params
  })
}

// 获取环境数据概览
export function getEnvironmentOverview(params) {
  return request({
    url: '/env/statistics/overview',
    method: 'get',
    params: params
  })
}

// 获取异常数据统计
export function getAbnormalDataStatistics(params) {
  return request({
    url: '/env/statistics/abnormal',
    method: 'get',
    params: params
  })
}

// 获取设备排行榜
export function getDeviceRanking(params) {
  return request({
    url: '/env/statistics/ranking',
    method: 'get',
    params: params
  })
}

// 获取环境舒适度分析
export function getComfortAnalysis(params) {
  return request({
    url: '/env/statistics/comfort',
    method: 'get',
    params: params
  })
}

// 获取实时统计数据
export function getRealtimeStatistics(deviceId) {
  return request({
    url: '/env/statistics/realtime',
    method: 'get',
    params: {
      deviceId: deviceId
    }
  })
}

// 获取多设备对比数据
export function getDeviceComparison(params) {
  return request({
    url: '/env/statistics/compare',
    method: 'get',
    params: params
  })
}

// 导出环境数据统计
export function exportStatistics(query) {
  return request({
    url: '/env/statistics/export',
    method: 'post',
    params: query
  })
}